package salesSystem.model;

import java.util.Date;
import java.util.List;
import java.util.UUID;

// 订单实体类
public class Order {
    private String orderId;
    private String customerId;
    private List<OrderItem> items;
    private double totalAmount;
    private String status; // CREATED, APPROVED, PAID, PACKED, SHIPPED, DELIVERED, CANCELLED
    private Date createTime;
    private Date updateTime;
    private String paymentMethod;
    private String shippingAddress;
    private String trackingNumber;

    // 构造方法
    public Order(String customerId, List<OrderItem> items, double totalAmount, String shippingAddress) {
        this.orderId = "ORD-" + UUID.randomUUID().toString().substring(0, 8);
        this.customerId = customerId;
        this.items = items;
        this.totalAmount = totalAmount;
        this.status = "CREATED";
        this.createTime = new Date();
        this.updateTime = new Date();
        this.shippingAddress = shippingAddress;
    }

    // Getters and Setters
    public String getOrderId() { return orderId; }
    public String getCustomerId() { return customerId; }
    public List<OrderItem> getItems() { return items; }
    public double getTotalAmount() { return totalAmount; }
    public String getStatus() { return status; }
    public void setStatus(String status) {
        this.status = status;
        this.updateTime = new Date();
    }
    public Date getCreateTime() { return createTime; }
    public Date getUpdateTime() { return updateTime; }
    public String getPaymentMethod() { return paymentMethod; }
    public void setPaymentMethod(String paymentMethod) { this.paymentMethod = paymentMethod; }
    public String getShippingAddress() { return shippingAddress; }
    public String getTrackingNumber() { return trackingNumber; }
    public void setTrackingNumber(String trackingNumber) { this.trackingNumber = trackingNumber; }

    @Override
    public String toString() {
        return "OrderSystem.model.Order [orderId=" + orderId + ", status=" + status + ", totalAmount=" + totalAmount + "]";
    }
}